﻿@{
    ViewBag.Title = "ViewPage1";
    Layout = "~/Views/Shared/BaseView.cshtml";
}
<link href="/Content/style/main.css" rel="stylesheet" type="text/css" />
<div style="width: 100%;" align="center">
    <div style="width: 750px;">
        <div style="font-size: 20pt; width: 100%; text-align: center; padding-top: 20px;">
            交易数据日报</div>
        <div style="font-size: 16pt; width: 100%; text-align: right; padding-right: 10%;">
            ——@ViewBag.queryday</div>
        <div style="font-size: 12pt; width: 100%; text-align: left;">
            一、交易员收入分析</div>
        <div>
            @{
                double value2 = 0f;
                double value3 = 0f;
                double value4 = 0f;
                double value5 = 0f;
            
            }
            @foreach (BenefitHelper.Data.Day.GroupDayChange group in ViewBag.groupweeksums)
            {
                <div style="height: 20px; line-height: 20px;">
                    <p>
                    </p>
                </div>
                <div style="text-align: left;">
                    @group.Group.GroupName</div>
                <div style="text-align: left;">
                    <table cellspacing="0" cellpadding="0" class="list" style="width: 100%;">
                        <tr>
                            <td class="title" style="text-align: right;">
                                总盈利
                            </td>
                            <td class="title" style="text-align: right;">
                                收益率
                            </td>
                            <td class="title" style="text-align: right;">
                                投资本金
                            </td>
                            <td class="title" style="text-align: right;">
                                期末结存
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right;">
                                @string.Format("{0:N2}", group.DayCount)
                                @{value2 += group.DayCount;
                                }
                            </td>
                            <td style="text-align: right;">
                                @group.Yield
                                @{value3 += group.Yield;
                                }
                            </td>
                            <td style="text-align: right;">
                                @foreach (KeyValuePair<int, double> kvp in ViewBag.groupMoney)
                                {
                                    if (kvp.Key == group.GroupId)
                                    {
                                    <span>@string.Format("{0:N2}", kvp.Value)</span>
                                    
                                     value4 += kvp.Value;
                                     break;
                                    }
                                }
                            </td>
                            <td style="text-align: right;" class="leftyes">
                                @foreach (KeyValuePair<int, double> kvp in ViewBag.groupMoney2)
                                {
                                    if (kvp.Key == group.GroupId)
                                    {
                                    <span>@string.Format("{0:N2}", kvp.Value)</span>
                                    
                                     value5 += kvp.Value;
                                     break;
                                    }
                                }
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: left; padding-left: 10px;">
                                盈利(由大到小)
                            </td>
                            <td style="text-align: left;" colspan="3" class="leftyes">
                                @foreach (BenefitHelper.Sys.DayGroupOperators dgo in ViewBag.ogos)
                                {
                                    if (dgo.GroupId == group.GroupId)
                                    {
                                        foreach (BenefitHelper.View.OperatorDayChange sum in ViewBag.operatorweeksums)
                                        {
                                            if (sum.OperatorId == dgo.OperatorId && sum.DayCount > 0)
                                            {
                                    <span style="padding-right: 10px;">@sum.Operator.UName</span>
                                            }
                                        }
                                    }
                                }
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: left; padding-left: 10px;" class="bottomyes">
                                亏损(由大到小)
                            </td>
                            <td style="text-align: left;" colspan="3" class="bottomyes leftyes">
                                @foreach (BenefitHelper.Sys.DayGroupOperators dgo in ViewBag.ogos)
                                {
                                    if (dgo.GroupId == group.GroupId)
                                    {
                                        foreach (BenefitHelper.View.OperatorDayChange sum in ViewBag.operatorweeksums)
                                        {
                                            if (sum.OperatorId == dgo.OperatorId && sum.DayCount <= 0)
                                            {
                                    <span style="padding-right: 10px;">@sum.Operator.UName</span>
                                            }
                                        }
                                    }
                                }
                            </td>
                        </tr>
                    </table>
                </div>
                
                
            }
            <div style="height: 20px; line-height: 20px;">
                <p>
                </p>
            </div>
            <div style="text-align: left;">
                公司小计</div>
            <div style="text-align: left;">
                <table cellspacing="0" cellpadding="0" class="list" style="width: 100%;">
                    <tr>
                        <td class="title" style="text-align: right;">
                            总盈利
                        </td>
                        <td class="title" style="text-align: right;">
                            收益率
                        </td>
                        <td class="title" style="text-align: right;">
                            投资本金
                        </td>
                        <td class="title" style="text-align: right;">
                            期末结存
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right;">
                            @string.Format("{0:N2}", value2)
                        </td>
                        <td style="text-align: right;">
                            @value3
                        </td>
                        <td style="text-align: right;">
                            @string.Format("{0:N2}", value4)
                        </td>
                        <td style="text-align: right;" class="leftyes">
                            @string.Format("{0:N2}", value5)
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div style="height: 30px; line-height: 30px;">
            <p>
            </p>
        </div>
        <div style="font-size: 12pt; width: 100%; text-align: left;">
            二、小组收入分析</div>
        <div>
            <div style="text-align: left;">
                <table cellspacing="0" cellpadding="0" class="list" style="width: 100%;" id="table1">
                    <tr>
                        <td class="title" style="text-align: left; padding-left: 10px; width: 10%;">
                            姓名
                        </td>
                        <td class="title" style="text-align: right;">
                            笔数
                        </td>
                        <td class="title" style="text-align: right;">
                            手续费
                        </td>
                        <td class="title" style="text-align: right;">
                            平仓盈亏
                        </td>
                        <td class="title" style="text-align: right;">
                            净盈利
                        </td>
                    </tr>
                    @{
                        double allbillcount = 0f;
                        double allfree = 0f;
                        double allprofit = 0f;
                        double alldaycount = 0f;
                    }
                    @foreach (BenefitHelper.Data.Day.GroupDayChange group in ViewBag.groupweeksums)
                    {
                        <tr>
                            <td style="text-align: left; padding-left: 10px;">
                                @group.Group.GroupName
                            </td>
                            <td style="text-align: right;">
                                @group.BillCount
                            </td>
                            <td style="text-align: right;">
                                @string.Format("{0:N2}", group.Free)
                            </td>
                            <td style="text-align: right;">
                                @string.Format("{0:N2}", group.Profit)
                            </td>
                            <td style="text-align: right;" class="leftyes">
                                @string.Format("{0:N2}", group.DayCount)
                            </td>
                        </tr>
                        
                           allbillcount += group.BillCount;
                           allfree += group.Free;
                           allprofit += group.Profit;
                           alldaycount += group.DayCount;

                    }
                    <tr>
                        <td style="text-align: left; padding-left: 10px;" class="bottomyes">
                            合计
                        </td>
                        <td style="text-align: right;" class="bottomyes">
                            @allbillcount
                        </td>
                        <td style="text-align: right;" class="bottomyes">
                            @string.Format("{0:N2}", allfree)
                        </td>
                        <td style="text-align: right;" class="bottomyes">
                            @string.Format("{0:N2}", allprofit)
                        </td>
                        <td style="text-align: right;" class="bottomyes leftyes">
                            @string.Format("{0:N2}", alldaycount)
                        </td>
                    </tr>
                </table>
            </div>
            <div style="height: 20px; line-height: 20px;">
                <p>
                </p>
            </div>
            <div>
                <div>
                    <div style="width: 100%; height: 300px;" id="showflash2">
                    </div>
                </div>
                @* <div>
                    <img src="/Content/images/2.png" />
                </div>*@
            </div>
        </div>
        <div style="height: 60px; line-height: 60px;">
            <p>
            </p>
        </div>
        <div style="font-size: 12pt; width: 100%; text-align: left;">
            三、持仓明细</div>
        @foreach (BenefitHelper.Sys.Groups group in ViewBag.groups)
        {
            int billcount = 0;
            double fudongyingki = 0f;
            double margin = 0f;
        
            <div style="height: 20px; line-height: 20px;">
                <p>
                </p>
            </div>
            <div style="text-align: left;">
                @group.GroupName</div>
            <div style="text-align: left;">
                <table cellspacing="0" cellpadding="0" class="list" style="width: 100%;">
                    <tr>
                        <td style="text-align: center;" class="title">
                            时间
                        </td>
                        <td style="text-align: center;" class="title">
                            价格
                        </td>
                        <td style="text-align: center;" class="title">
                            合约
                        </td>
                        <td style="text-align: center;" class="title">
                            买/卖
                        </td>
                        <td style="text-align: center;" class="title">
                            手数
                        </td>
                        <td style="text-align: center;" class="title">
                            浮动盈亏
                        </td>
                        <td style="text-align: center;" class="title">
                            占用保证金
                        </td>
                    </tr>
                    <!--表格正文-->
                    @foreach (BenefitHelper.View.OperatorDayPosition accountdayposition in ViewBag.groupMoney3)
                    {
                        if (accountdayposition.Investorid.Equals(group.Id.ToString()))
                        {
                            
                        <tr class="@accountdayposition.AccountId positiondiv">
                            <td title="">
                                @{
                              if (accountdayposition.OpenTime.ToString().Length == 5)
                              {
                                    @(accountdayposition.OpenTime.ToString().Substring(0, 1) + ":" + accountdayposition.OpenTime.ToString().Substring(1, 2) + ":" + accountdayposition.OpenTime.ToString().Substring(3))
                              }
                              else
                              {
                                    @(accountdayposition.OpenTime.ToString().Substring(0, 2) + ":" + accountdayposition.OpenTime.ToString().Substring(2, 2) + ":" + accountdayposition.OpenTime.ToString().Substring(4))
                              }
                                }
                            </td>
                            <td style="text-align: right;">
                                @string.Format("{0:N2}", accountdayposition.OpenPrice)
                            </td>
                            <td>
                                @accountdayposition.InstrumentId
                            </td>
                            <td>
                                @if (accountdayposition.Direction.Equals("0"))
                                {
                                    <span>买</span>
                                }
                                else
                                {
                                    <span>卖</span>
                                }
                            </td>
                            <td style="text-align: right;">
                                @accountdayposition.Volume
                                @{billcount += accountdayposition.Volume;}
                            </td>
                            <td style="text-align: right;">
                                @string.Format("{0:N2}", accountdayposition.PositionProfit)
                                @{fudongyingki += accountdayposition.PositionProfit;
                                }
                            </td>
                            <td class="leftyes" style="text-align: right;">
                                @string.Format("{0:N2}", accountdayposition.Margin)
                                @{margin += accountdayposition.Margin;
                                }
                            </td>
                        </tr>
                        }
                    }
                    <tr>
                        <td title="" class="bottomyes">
                            合计
                        </td>
                        <td class="bottomyes">
                        </td>
                        <td class="bottomyes">
                        </td>
                        <td class="bottomyes">
                        </td>
                        <td class="bottomyes" style="text-align: right;">
                            @billcount
                        </td>
                        <td class="bottomyes" style="text-align: right;">
                            @string.Format("{0:N2}", fudongyingki)
                        </td>
                        <td class="leftyes bottomyes" style="text-align: right;">
                            @string.Format("{0:N2}", margin)
                        </td>
                    </tr>
                </table>
            </div>
                
                
        }
        <div style="height: 60px; line-height: 60px;">
            <p>
            </p>
        </div>
    </div>
</div>
@MvcHtmlString.Create(ViewBag.billpic)
<script type="text/javascript">    ProductPie(); </script>
